OPENSSL_URL = "http://www.openssl.org/source/openssl-%(VERSION)s.tar.gz"
OPENSSL_URL = "https://www.openssl.org/source/openssl-%(VERSION)s.tar.gz"
DEFAULT_VERSION = "0.9.8g"
VERSIONS = ["0.9.8g", "0.9.8g_static", "1.0.1j" ]

OPENSSL_WIN32_URL = "http://www.ie7pro.com/openssl/openssl-%(VERSION)s_win32.zip"
OPENSSL_X64_URL = "http://www.ie7pro.com/openssl/openssl-%(VERSION)s_x64.zip"

def urldecider( machine, dirs, version):
  linuxurl = OPENSSL_URL % {"VERSION" : version}
  winurl32 = OPENSSL_WIN32_URL % {"VERSION" : version}
  winurl64 = OPENSSL_X64_URL % {"VERSION" : version}
  return { "Linux32" : linuxurl,
           "Linux64" : linuxurl,
           "Windows32" : winurl32 ,
           "Windows64" : winurl64 }[machine.platform+str(machine.bits)]

URL = urldecider

from source.builders import ConfigureMakeBuilder, DownloadAndCopyBuilder
import os

class OpenSSLConfigureMakeBuilder( ConfigureMakeBuilder ):
  """ subclass of ConfigureMakeBuilder with custom configure step """

  def configure(self):
    os.chdir( self.extractedpath )
    parameters = self.configureparameters()
    self.execute( "./config --prefix=" + self.installpath() + " --openssldir=" + self.installpath()+"/openssl" )

def decider( machine, dirs ):
  return { "Linux" : OpenSSLConfigureMakeBuilder,
           "Windows" : DownloadAndCopyBuilder }[machine.platform]

BUILDER = decider

